<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1 style="display: inline-block" id="title">调拨单查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <div class="row">
                        <div class="form-inline">
                            <form id="queryForm">
                                <div class="form-group">
                                    <label>
                                        调拨类型
                                    </label>
                                    <select name="odrType" class="form-control select">
                                        <option value="" selected>全部</option>
                                        <option value="1">外购件调拨</option>
                                        <option value="2">原材料调拨</option>
                                        <option value="3">外协件调拨</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>
                                        出库仓
                                    </label>
                                    <input name="odrOutWhiName" type="text" class="form-control text"
                                           placeholder="请输入出库仓"/>
                                </div>
                                <div class="form-group">
                                    <label>
                                        入库仓
                                    </label>
                                    <input name="odrInWhiName" type="text" class="form-control text" maxlength="255"
                                           placeholder="请输入入库仓"/>
                                </div>
                                <div class="form-group">
                                    <label>
                                        调拨单号
                                    </label>
                                    <input name="odrCode" type="text" class="form-control text" maxlength="255"
                                           placeholder="请输入调拨单号"/>
                                </div>
                                <div class="form-group">
                                    <label>物料描述</label>
                                    <input type="text" id="ardMatName" name="ardMatName"
                                           class="form-control"
                                           placeholder="请输入物料描述">
                                </div>
                                <div class="form-group">
                                    <label>
                                        制单人
                                    </label>
                                    <input name="odrMakePersonId" type="text" class="form-control text" maxlength="255"
                                           placeholder="请输入制单人"/>

                                </div>
                                <!--<div class="form-group">
                                    <label>制单时间</label>
                                    <input type="text" class="form-control datepicker" id="startOdrMakeDate"
                                           name="startOdrMakeDate" readonly="readonly"/>
                                    <span>至</span>
                                    <input type="text" class="form-control datepicker" id="endOdrMakeDate"
                                           name="endOdrMakeDate" readonly="readonly"/>
                                </div>-->
                                <div class="form-group">
                                    <button type="button" class="btn btn-success" id="btn-search">搜索
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"  style="word-break:break-all; word-wrap:break-all;" width="100%">
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var table;

    $(function () {
        //加载列表数据
        table = js.table.init({
            id: 'bootstrap-table',
            url: ctx + "allocationQuery/list",
            showColumns: true,
            showExport: false,
            pageSize: 300,
            striped: false,
            uniqueId: "odrId",
            columns: [
                {
                    title: '序号', field: 'odrId', width: '40',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '调拨单号', field: 'odrCode'},
                {title: '调拨类型', field: 'odrType',
                    formatter: function (value, row, index) {
                    if(value == 1){
                        return "外购件调拨";
                    }else if(value == 2){
                        return "原材料调拨";
                    }else if(value == 3){
                        return "外协件调拨";
                    }else {
                        return value;
                    }
                    }},
                {title: '出库仓', field: 'odrOutWhiName'},
                {title: '入库仓', field: 'odrInWhiName'},
                {title: '备注', field: 'odrRemark'},
                {title: '制单人', field: 'odrMakePersonId'},
                {title: '出入库状态', field: 'odrOutStatus',
                    formatter: function (value, row, index) {
                        if(value == 1){
                            return "未出库"
                        }else if(value == 2){
                            return "已出库"
                        }else if(value == 3){
                            return "已入库"
                        }else {
                            return value
                        }
                    }
                },
                {title: '物料描述', field: 'ardMatName'},
                {title: 'SAP<br>物料编码', field: 'ardSapCode'},
                {title: '项目编号', field: 'ardProCode'},
                {title: '项目名称', field: 'ardProName'},
                {title: '跟踪号', field: 'ardTrackCode'},
                {title: '在库类型', field: 'ardStockType',
                    formatter: function (value, row, index) {
                        if(value == 1){
                            return "库存在库"
                        }else if(value == 2){
                            return "项目在库"
                        }else {
                            return value
                        }
                    }},
                {title: '出库<br>数量', field: 'ardOutNum'},
                {title: '入库<br>数量', field: 'ardInNum',
                    formatter: function (value, row, index) {
                    if(row.odrOutStatus != 3){
                        return "-"
                    }else
                    if(row.odrOutStatus == 3 && (value == undefined || value == null)){
                        return row.ardOutNum
                    } else {
                            return value
                        }
                    }
                },
                {title: '出库<br>重量', field: 'ardOutWeight'},
                {title: '入库<br>重量', field: 'ardInWeight',
                    formatter: function (value, row, index) {
                    if(row.odrOutStatus != 3){
                        return "-"
                    }else
                        if(row.odrOutStatus == 3 && (value == undefined || value == null)){
                            return row.ardOutWeight
                        }else {
                            return value
                        }
                    }},
                {title: '单价', field: 'ardPrice'},
                {title: '单位', field: 'ardUnit'},
                {title: '特殊说明', field: 'ardSpecialRemark'},
                {
                    title: '操作', field: 'odrId',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(row.odrStatus == 3 || row.odrOutStatus == 2 || row.odrOutStatus == 3){
                            actions.push('<a class="btn btn-info btn-xs" href="/allocationOrder/allocationOrderDetailView/' + row.odrId + '">查看</a>');
                        }
                        return actions.join('');
                    }
                }
            ],
            rowStyle: function (row, index) {
                if (row.odrOutStatus == 3 && row.ardInNum !=null && row.ardOutNum != row.ardInNum) {
                    return {css: {"color": "blue"}}
                } else {
                    return {css: {"color": "black"}}
                }
            }
        });
        /**
         * 表格搜索
         */
        $("#btn-search").on('click', function () {
            js.table.search(table);
        });

    });
</script>
</body>
</html>
